 <form method="post" action="/_api" target="ifr_form" autocomplete="off" id="form_api_caller">
     <input type="hidden" name="do" value="caller">
     <input type="hidden" name="api_name" value="{{$.api.Name}}">
            
    <fieldset>
    <legend>
    IP标记客户端 <a onclick="return proxy_api_caller_add();" href="#">+</a>
    </legend>
    <p class="text-muted" style="font-size:-2">IP的<a href="/#adv">优先级</a>低于GET/POST、Header、Cookie参数</p>
    {{range $i,$caller:=.api.Caller}}
    <div class="{{if eq $caller.IP ""}}hidden api_caller_tpl{{end}}">
         {%my_include "api/form_caller_panel.html"%}
      </div>      
    {{end}}
    </fieldset>
    {%my_include "api/submit.html"%}
 </form>
{{if .userCanEdit}}
	<script>
	function proxy_api_caller_del(obj){
	    var div=$(obj).parents("div.api_caller");
	    var ip=div.find("input[name=ip]").val();
	    if(ip!="" && !confirm("确定要删除(ip="+ip+")吗?")){
	        return false;
	    }
	    div.remove();
	    return false;
	}
	function proxy_api_caller_add(){
	    var tpl=$("#form_api_caller .api_caller_tpl").eq(0).clone();
	    tpl.find(":input").removeAttr("disabled")
	    var html=tpl.html()
	    $("#form_api_caller fieldset").append(html)
	    return false;
	}
	
	$().ready(function(){
	    var caller_form=$("#form_api_caller");
	    caller_form.find(".api_caller_tpl :input").attr("disabled","disabled")
	    caller_form.submit(function(){
	        var datas=[]
	        $(this).find("div.api_caller:visible").each(function(){
	            datas.push($(this).find("input").serialize())
	        });
	        var params={
	                "api_name":caller_form.find("input[name=api_name]").val(),
	                 "do":"caller",
	                 "datas":datas
	        }
	        $.post("/_api",params,function(data){
	            alert(data.msg)
	            if(data.code==0){
	                location.reload()
	            }
	        })
	        return false;
	    });
	});
	</script>
{{end}}